#!/bin/bash

ip addr | grep wwan0
if [ $? -eq 0 ]; then
	ping -c 3 www.baidu.com > /dev/null
	if [ $? -ne 0 ]; then
		echo -ne 'AT+CFUN=0\n' > /dev/ttyUSB2
		sleep 1
		echo -ne 'AT+CFUN=1\n' > /dev/ttyUSB2
	fi
else
	echo -ne 'AT+CFUN=0\n' > /dev/ttyUSB2
	sleep 1
	echo -ne 'AT+CFUN=1\n' > /dev/ttyUSB2
fi
